package com.shop.cereshop.app.controller.tencent.im;

import com.shop.cereshop.app.tencent.im.model.notice.SendNoticeParam;
import com.shop.cereshop.app.tencent.im.model.msg.BaseSendMsgParam;
import com.shop.cereshop.app.tencent.im.service.MsgService;
import com.shop.cereshop.commons.tencent.im.enums.notice.SysNoticeTypeEnum;
import com.shop.cereshop.commons.tencent.im.enums.notice.SysNoticeTargetTypeEnum;
import com.shop.cereshop.commons.result.Result;
import com.shop.cereshop.commons.tencent.im.model.dto.SysNoticeTypeDTO;
import com.shop.cereshop.commons.tencent.im.model.dto.TargetTypeDTO;
import com.shop.cereshop.commons.tencent.im.model.msg.data.MsgData;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @description: 腾讯IM 消息接口
 * @author zdd
 * @date 2025/9/3 14:36
 * @version 1.0
 */
@RestController
@RequestMapping("/tim/msg")
@Slf4j(topic = "TimMsgController")
@Api(value = "腾讯IM 消息接口", tags = "腾讯IM 消息接口")
public class TimMsgController {

    @Resource
    private MsgService msgService;

    @ApiOperation(value = "单发单聊消息")
    @PostMapping("/c2c/send")
    public Result<Void> sendC2cMsg(@Validated @RequestBody BaseSendMsgParam<MsgData> param) {
        return msgService.sendC2cMsg(param);
    }

    @ApiOperation(value = "获取系统通知类型列表")
    @GetMapping("/notice/type/list")
    public Result<List<SysNoticeTypeDTO>> getSysNoticeTypeList() {
        return Result.success(SysNoticeTypeEnum.SYS_NOTICE_TYPE_LIST);
    }

    @ApiOperation(value = "获取系统通知目标类型列表")
    @GetMapping("/notice/target-type/list")
    public Result<List<TargetTypeDTO>> getTargetTypeList() {
        return Result.success(SysNoticeTargetTypeEnum.getTargetTypeList());
    }

    @ApiOperation(value = "发送系统通知")
    @PostMapping("/notice/send")
    public Result<Void> sendSysNotice(@Validated @RequestBody SendNoticeParam param) {
        return msgService.sendSysNotice(param);
    }

}
